package net.xxcxcxcx.xc_enhancedmob.skills.basics.individual.mystery;

import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.nbt.NbtCompound;
import net.xxcxcxcx.xc_enhancedmob.config.skill.SkillConfig;
import net.xxcxcxcx.xc_enhancedmob.skills.BaseSkill;
import net.xxcxcxcx.xc_enhancedmob.skills.SkillRarity;


public class RebirthSkill extends BaseSkill {

    public RebirthSkill(int level) {
        super(level);
    }

    public RebirthSkill(NbtCompound nbtCompound) {
        super(nbtCompound);
    }

    public RebirthSkill() {
    }

    @Override
    public SkillConfig getDefaultConfig() {
        SkillConfig skillConfig = super.getDefaultConfig();
        skillConfig.setMaxUseCount(1);
        skillConfig.setMessage(getConfigMessage(skillConfig));
        return skillConfig;
    }

    @Override
    public String getConfigMessage(SkillConfig skillConfig) {
        if (skillConfig == null) return super.getConfigMessage(null);
        return String.format("重生技能，死亡时满状态复活。");
    }

    @Override
    public SkillRarity getSkillRarity() {
        return SkillRarity.Mystery;
    }

    @Override
    public boolean onDeath(LivingEntity attacker, MobEntity target, DamageSource source, boolean ismob, boolean remote) {
        if (getMaxUseCount() > getSkillUsecount()) {
            setSkillUsecount(getSkillUsecount() + 1);
            target.setHealth(target.getMaxHealth());
            return false;
        }
        return true;
    }
}

